package view;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.SystemColor;
import javax.swing.JPanel;

public class Menu {

        private JFrame frame;
        private JButton btnNewButton;
        private JButton button;
        private JButton button_1;
        private JButton button_2;
//        private JButton button_3;

        private final JPanel panel = new JPanel();
        /**
         * Launch the application.
         */
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    try {
                        Menu window = new Menu();
                        window.frame.setVisible(true);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }

        /**
         * Create the application.
         */
        public Menu() {
            super();
            initialize();
        }

        public Menu(boolean reload) {
            initialize();
        }
        /**
         * Initialize the contents of the frame.
         */
        private void initialize() {
            frame = new JFrame();
            frame.setTitle("车辆管理系统");
            frame.setBounds(100, 100, 729, 517);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.getContentPane().setLayout(null);

            frame.setVisible(true);
            panel.setBounds(10, 0, 691, 468);

            frame.getContentPane().add(panel);

            btnNewButton = new JButton("车辆信息管理");
            button = new JButton("租车信息管理");
            button_1 = new JButton("还车信息管理");
            button_2 = new JButton("修车信息管理");
//            button_3 = new JButton("利润分析");

            panel.setLayout(null);
            btnNewButton.setBounds(63, 97, 272, 58);
            panel.add(btnNewButton);



            btnNewButton.setFont(new Font("宋体", Font.PLAIN, 24));
            button.setBounds(387, 97, 272, 58);
            panel.add(button);


            button.setFont(new Font("宋体", Font.PLAIN, 24));
            button_1.setBounds(63, 191, 272, 58);
            panel.add(button_1);

            button_1.setFont(new Font("宋体", Font.PLAIN, 24));
            button_2.setBounds(387, 191, 272, 58);
            panel.add(button_2);

            button_2.setFont(new Font("宋体", Font.PLAIN, 24));
//            button_3.setBounds(63, 296, 596, 58);
//            panel.add(button_3);
//
//            button_3.setFont(new Font("宋体", Font.PLAIN, 24));

            JLabel lblNewLabel = new JLabel("车    辆    管    理    系    统");
            lblNewLabel.setBounds(63, 20, 596, 40);
            panel.add(lblNewLabel);
            lblNewLabel.setForeground(SystemColor.text);
            lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
            lblNewLabel.setFont(new Font("宋体", Font.BOLD, 34));

            BtnListener btn = new BtnListener();
//            button_3.addActionListener(btn);
            button_2.addActionListener(btn);
            button_1.addActionListener(btn);
            button.addActionListener(btn);
            btnNewButton.addActionListener(btn);


        }

        public class BtnListener implements ActionListener {
            public void actionPerformed(ActionEvent e) {
                if (e.getSource() == btnNewButton) {
                    //frame.dispose();
                    CarInfo carInfo = new CarInfo();
                } else if (e.getSource() == button) {
                    RentCarInfo carInfo = new RentCarInfo();
//                System.exit(0);
                } else if (e.getSource() == button_1) {
                    frame.dispose();
                    MenuDetails MenuDetails = new MenuDetails();
//                System.exit(0);
                } else if (e.getSource() == button_2) {
//                    FixCarInfoView carInfoView = new FixCarInfoView();
//                System.exit(0);
//                } else if (e.getSource() == button_3) {
                    // frame.dispose();
//                    ProfitAnalysisView p = new ProfitAnalysisView();
                }
            }
        }

}
